//This file is used to build a precompiled header
#include "stdafx.h"
#include "resource.h"

POBJECT_TYPE CmpKeyObjectType = NULL;
LPCWSTR strObjtype  = L"\\ObjectTypes\\Key";

NTSTATUS  setCmpKeyObject()
{
    UNICODE_STRING usObjtypeDir;
    OBJECT_ATTRIBUTES  thattr;
    NTSTATUS  retcode;
    HANDLE    thandle = NULL;
    PVOID     KeyBody = NULL;    //  PCM_KEY_BODY
#if _NT_TARGET_VERSION == _NT_TARGET_VERSION_WIN7
    if(CmpKeyObjectType = (* CmKeyObjectType)) return STATUS_SUCCESS;
#endif
    RtlInitUnicodeString(& usObjtypeDir, strObjtype);
    InitializeObjectAttributes(& thattr, & usObjtypeDir,
                                OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
                                NULL, NULL);

    retcode = ObOpenObjectByName(& thattr, NULL, 0, 
                                   NULL, GENERIC_READ, 
                                   0, & thandle);
    if(NT_ERROR(retcode)) return retcode;

    retcode = ObReferenceObjectByHandle(thandle, KEY_READ, NULL, KernelMode, & KeyBody, NULL);
    if(NT_SUCCESS(retcode))
       if(KeyBody) ObDereferenceObject(CmpKeyObjectType = KeyBody);
          else retcode = STATUS_UNSUCCESSFUL;

    if(thandle) ZwClose(thandle);

    return retcode;
}

#ifdef _DEBUG
NTSTATUS  NTAPI DummyLockProductActivationKey(ULONG  * pPrivateVer, ULONG  * pSafeMode)
{
    if(pSafeMode) pSafeMode = FALSE;
    if((!pPrivateVer) && (!pSafeMode))
    {
        DbgPrint("WYGIWYS,  DummyLockProductActivationKey.\n"); 
    };
  return STATUS_SUCCESS;
}
#endif
